﻿using Shop.RemoteModel.PageModuleGoods;
using Shop.RemoteModel.PageModuleGoods.Model;
using Shop.RemoteModel.SpuGoods;
using Shop.RemoteModel.SpuGoods.Model;
using Shop.StoreGatewayModular.Interface;
using Shop.StoreGatewayModular.Model.ModuleGoods;
using WeDonekRpc.Client;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Service
{
    internal class ModuleGoodsService : IModuleGoodsService
    {
        public ModuleGoodsDto[] Gets ( long tModuleId, string tag )
        {
            return new GetModuleGoods
            {
                TagKey = tag,
                TModuleId = tModuleId
            }.Send();
        }
        public PagingResult<SpuDatum> Query (PagingParam<SpuGetArg> param)
        {
            return new QueryModuleSpu
            {
                Index = param.Index,
                Size = param.Size,
                SortName = param.SortName,
                IsDesc = param.IsDesc,
                NextId = param.NextId,
                TagKey = param.Query.Tag,
                TModuleId = param.Query.ModuleId
            }.Send();
        }
        public void Delete ( long id )
        {
            new DeleteModuleGoods
            {
                Id = id
            }.Send();
        }
        public void Delete ( long[] ids )
        {
            new BatchDeleteModuleGoods
            {
                Ids = ids
            }.Send();
        }
        public ModuleGoodsDto[] Sync ( ModuleGoodsAdd add )
        {
            return new SyncModuleGoods
            {
                Datum = add
            }.Send();
        }

        public Dictionary<long, int> SetSort ( long id, int sort )
        {
            return new SetModuleGoodsSort
            {
                Id = id,
                Sort = sort
            }.Send();
        }

        public SpuDatum[] GetTops ( SpuGetTopArg obj )
        {
            return new GetsModuleTopGoods
            {
                Top = obj.Top,
                TagKey = obj.Tag,
                ModuleId = obj.ModuleId
            }.Send();
        }
    }
}
